#include "DataTypeCompany.h"
#include "Sqlite3Database.h"

#include <cstdlib>
using namespace std;

int main()
{
    DataTypeCompany *company = new DataTypeCompany();
    Sqlite3Database  sqlite3DB;
    if (!sqlite3DB.sqlite3Open("test.db")) {
        exit(EXIT_FAILURE);
    }

    company->getCreateSql();

    std::string create_sql = company->getCreateSql();
    sqlite3DB.sqlite3Exec(create_sql);

    for (int i = 0; i < 10; i++) {
        company_t data;
        data.id                = i + 1;
        data.name              = "jack";
        data.age               = i + 30;
        data.address           = "hello";
        data.salary            = (i + 1) * 1000.0;
        std::string insert_sql = company->getInsertSql(data);

        sqlite3DB.sqlite3Exec(insert_sql);
    }

    std::string select_sql = company->getSelectSql();
    sqlite3DB.sqlite3Exec(select_sql, DataTypeCompany::callback, (void *)company);

    sqlite3DB.sqlite3Close();
    return 0;
}